<template>
  <div class="gotoTop">返回<br>顶部</div>
</template>

<script>
export default {
  name: 'tHead',
  data () {
    return {
      
    }
  },
  mounted(){
    this.gotoTop();
  },
  methods:{
    gotoTop:function(){
      window.addEventListener('scroll',function(){
          let scrollTopV=document.documentElement.scrollTop;
          if(scrollTopV>800){
            document.querySelector('.gotoTop').style.display='block';
          }else{
            document.querySelector('.gotoTop').style.display='none';
          }
      },false),
      document.querySelector('.gotoTop'),addEventListener('click',function(){
        document.documentElement.scrollTop=0;
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
